package nullby.common.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public final class ReaderFromStream {

	private static final String TAG = ReaderFromStream.class.getSimpleName();

	private static final int BUFFER_SIZE = 1024;

	public static final String readString(final InputStream in)
			throws IOException {

		final StringBuilder sb = new StringBuilder();
		try {
			final BufferedReader r = new BufferedReader(new InputStreamReader(
					in), BUFFER_SIZE);
			for (String line = r.readLine(); line != null; line = r.readLine()) {
				sb.append(line);
			}
		} catch (Exception e) {
			CustomLog.logE(TAG, "IOException : ", e);
		} finally {
			in.close();
		}
		return sb.toString();
	}
}
